package net.hnedu.config;

import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.hnedu.xml.DOM4JConfiguration;

public class ResConfigFactory {
  private static Log log = LogFactory.getLog(ResConfigFactory.class);
  private static String luceneAnalyzerClassName =
      "org.apache.lucene.analysis.standard.StandardAnalyzer";

  private static final String OPTION_FILE_NAME = "res.xml";

  public static String getLuceneAnalyzerClassName() {
    return luceneAnalyzerClassName;
  }

  static {
    try {
      String strPathName = ResConfig.CLASS_URL;
      String configFilename = strPathName + OPTION_FILE_NAME;
      DOM4JConfiguration conf = new DOM4JConfiguration(new File(configFilename));

      luceneAnalyzerClassName = conf.getString(
          "resfactoryconfig.lucene_analyzer_implementation",
          luceneAnalyzerClassName);
    }
    catch (Exception e) {
      log.error("Error loading the factory properties", e);
    }
  }
}
